package com.aegean.onlinebook.service.business.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aegean.onlinebook.model.BigType;
import com.aegean.onlinebook.model.ServiceValue;
import com.aegean.onlinebook.model.SmallType;
import com.aegean.onlinebook.service.business.ServiceBusiness;
import com.aegean.onlinebook.service.dao.ServiceDao;

@Service
@Transactional
public class ServiceBusinessImpl implements ServiceBusiness {
	@Resource
	ServiceDao dao;

	@Override
	public void insertService(ServiceValue service) {
		dao.insertService(service);
	}

	@Override
	public boolean searchService(ServiceValue service) {
		// TODO Auto-generated method stub
		if (service.getUser_Login() == null
				|| service.getUser_Password() == null
				|| service.getUser_Login().length() == 0
				|| service.getUser_Password().length() == 0)
		{
			return false;
		}else{
			boolean result=dao.searchService(service);
			return result;
		}
		
	}

	@Override
	public int searchBigTypeCount() {
		return dao.searchBigTypeCount();
	}

	@Override
	public List<BigType> searchPartBigTypes(int start, int limit) {
		return dao.searchPartBigTypes(start, limit);
	}

	@Override
	public boolean searchBigType(String name) {
		boolean result=dao.searchBigType(name);
		if(result==true){
			return false;
		}else{
			return true;
		}
	}
	@Override
	public boolean searchSmallType(String name) {
		boolean result=dao.searchSmallType(name);
		if(result==true){
			return false;
		}else{
			return true;
		}
	}

	public boolean addBigType(BigType one) {
		return dao.addBigType(one);
	}
	public boolean addSmallType(SmallType one,int bigType_Id) {
		return dao.addSmallType(one,bigType_Id);
	}
	@Override
	public boolean editBigType(BigType one) {
		// TODO Auto-generated method stub
		return dao.editBigType(one);
	}
	public boolean editSmallType(SmallType one) {
		// TODO Auto-generated method stub
		return dao.editSmallType(one);
	}
	@Override
	public boolean deleteBigType(String[] big_Name) {
		return dao.deleteBigType(big_Name);
	}

	@Override
	public int searchSmallTypeCount(String bigName) {
		return dao.searchSmallTypeCount(bigName);
	}

	@Override
	public List<SmallType> searchPartSmallTypes(String bigName, int start,
			int limit) {
		return dao.searchPartSmallTypes(bigName, start, limit);
	}

}
